package com.moji.controller.api;


import com.moji.common.base.ApiResult;
import com.moji.entity.MjProductPurchasePrice;
import com.moji.entity.dto.MjProductPurchasePriceDto;
import com.moji.entity.dto.QueryProductPurchasePriceDto;
import com.moji.service.MjProductPurchasePriceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 产品选购价格表 前端控制器
 * </p>
 *
 * @author ccl
 * @since 2024-10-14
 */
@RestController
@RequestMapping("/api/mjProductPurchase_price")
@Api(tags = "产品选购api价格相关接口", value = "产品选购api价格相关接口")
public class MjProductPurchasePriceController {
    @Resource
    private MjProductPurchasePriceService mjProductPurchasePriceService;
    @PostMapping("/queryByPage")
    @ApiOperation(value = "产品选购价格_分页查询",response = MjProductPurchasePrice.class)
    public ApiResult queryByPage(@RequestBody QueryProductPurchasePriceDto dto){
        return ApiResult.ok(mjProductPurchasePriceService.queryByPage(dto));
    }

    @PostMapping("/detail")
    @ApiOperation(value = "产品选购价格_详情",response = MjProductPurchasePrice.class)
    public ApiResult detail(@RequestParam("id") Long id){
        return ApiResult.ok(mjProductPurchasePriceService.detail(id));
    }

    @PostMapping("/add")
    @ApiOperation(value = "产品选购价格_新增",response = Boolean.class)
    public ApiResult add(@Validated @RequestBody MjProductPurchasePrice mjProductPurchasePrice){
        return ApiResult.ok(mjProductPurchasePriceService.add(mjProductPurchasePrice));
    }

    @PostMapping("/edit")
    @ApiOperation(value = "产品选购价格_编辑",response = Boolean.class)
    public ApiResult edit(@Validated @RequestBody MjProductPurchasePrice mjProductPurchasePrice){
        return ApiResult.ok(mjProductPurchasePriceService.edit(mjProductPurchasePrice));
    }

    @GetMapping("/delete")
    @ApiOperation(value = "产品选购价格_删除",response = Boolean.class)
    public ApiResult delete(@RequestParam("id") Long id){
        return ApiResult.ok(mjProductPurchasePriceService.delete(id));
    }


    @PostMapping("/editPriceStatus")
    @ApiOperation(value = "产品选购_更新价格和状态",response = Boolean.class)
    public ApiResult editPriceStatus(@RequestBody MjProductPurchasePriceDto mjProductPurchasePrice){
        return ApiResult.ok(mjProductPurchasePriceService.editPriceStatus(mjProductPurchasePrice));
    }
}

